#include "parseCmdMCode.hpp"
#include "parseCMDConfig.hpp"
#include "parseCMDDebug.hpp"
#include "../Global/GlobalDefs.hpp"
#include "../Global/globalVars.hpp"
#include "../Interface/report.hpp"
#include "../Misc/misc.hpp"
#include "../LedControl/ledControl.h"

#include "parseCMD.hpp"

void printModel();
void printIdentifier();
void printVer();
void printLocation();

void parseCMD(const char* cmdIn)
{
	if (StartWith(cmdIn, "who"))
	{
		printModel();
		return;
	}
	if (StartWith(cmdIn, "which"))
	{
		printIdentifier();
		return;
	}
	if (StartWith(cmdIn, "version"))
	{
		printVer();
		return;
	}
	if (StartWith(cmdIn, "where"))
	{
		printLocation();
		return;
	}
	if (StartWith(cmdIn, "identify")) {
		LedControl::setModeIdentify();
		return;
	}
	if (parseCmdMCode(cmdIn))
	{
		return;
	}
	if (parseCMDDebug(cmdIn))
	{
		return;
	}
	if (parseCMDConfig(cmdIn))
	{
		return;
	}
	Serial.print("Undefined command{");
	Serial.print(cmdIn);
	Serial.print("}\r\n");
	Serial.flush();
}

void printModel()
{
	Serial.print(Report::reportModelAndUUID());
	Serial.flush();
}

void printIdentifier() {
	Serial.print(GlobalVars::identifier);
	Serial.print("\r\n");
	Serial.flush();
}

void printVer()
{
	Serial.print(version);
	Serial.print("\r\n");
	Serial.flush();
}

void printLocation()
{
	// detect from RFID
	Serial.print("Unsure");
	Serial.print("\r\n");
	Serial.flush();
}